package com.gitee.huanminabc.demo.config;

import com.gitee.huanminabc.demo.spring.interceptor.DemoInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private DemoInterceptor demoInterceptor;
    /**
     * 注册自定义拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        //  /** 代表拦截所有请求  执行顺序和配置顺序有关系，即先配置顺序就在前
        //        添加拦截器
//        registry.addInterceptor(demoInterceptor )
//                .addPathPatterns("/**") //定义拦截路径
//                .excludePathPatterns("/**/*.js","/**/*.html","/**/*.css","/images/**","/fonts/**");//定义放行路径
    }

}
